<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>商铺信息</title>
    <link rel="stylesheet" href="/pc/layui/css/layui.css" media="all" />
</head>
<body>
      {{csrf_field()}}
    <blockquote class="layui-elem-quote news_search" style="margin-top:1.2em;">
    <div class="layui-inline" style="width: 70px;height: 70px;background: #2fa89d;border-radius: 50%"><img src="/staff/store/img/sp.png" style="width:50px;margin-top:10px;margin-left:10px;"></div>
     <div class="layui-inline">
      <a class="layui-btn linksAdd_btn" style="background-color:#1aa094;"> <img src="/staff/storage/img/tj2.png" style="margin-right: 10px;height: 36px;margin-bottom: 2px;">添加商铺</a>
     </div>
    </blockquote>
@if(!empty($areaArr))
    <div class="layui-collapse" lay-accordion="">
        @foreach($areaArr as $vel)
            <div class="layui-colla-item">
                <h2 class="layui-colla-title" style="background:#1aa094">{{$vel['name']}}</h2>
                @if(!empty($vel['roomArr']))
                    <div class="layui-colla-content">
                        <div class="layui-collapse" lay-accordion="">
                            @foreach($vel['roomArr'] as $v)
                                <div class="layui-colla-item" onclick="applyStore({{$v['id']}})"  id="store_{{$v['id']}}" >
                                    <h2 class="layui-colla-title"  style="background:#3cbf8a;position: relative">{{$v['name']}}
                                    <a class="layui-btn layui-btn-mini links_work" style="position:absolute;left:84.5%;top:24%;"  work="{{$v['id']}}"><img src="/staff/store/img/gd.png" style="margin-bottom: 1px"> 工单</a>
                                    <a class="layui-btn layui-btn-mini links_edit" style="position:absolute;left:88%;top:24%;"  store="{{$v['id']}}"><img src="/staff/storage/img/bj.png" style="margin-bottom: 1px"> 编辑</a>
                                    <a class="layui-btn layui-btn-danger layui-btn-mini links_del" data-id="1" style="position:absolute;left:92%;top:24%;" onclick="delStore({{$v['id']}})"><i class="layui-icon"></i> 删除</a>
                                    </h2>  
                                    
                                    <div class="layui-colla-content apply_{{$v['id']}}">
                                    </div>     
                                </div>
                            @endforeach
                        </div>
                    </div>
                @endif
            </div>
        @endforeach
    </div>
@endif
<script type="text/javascript" src="/staff/layout/js/jquery.min.js"></script>
<script type="text/javascript" src="/staff/layui/layui.js"></script>
<script type="text/javascript" src="/staff/store/js/store.js"></script>
<script>
    layui.use(['element', 'layer','form'], function(){
        var element = layui.element();
        var layer = layui.layer;
        //监听折叠
        element.on('collapse(test)', function(data){
            layer.msg('展开状态：'+ data.show);
        });
    });
     function delStore(id){  //删除
        layer.confirm('确定删除此信息？',{icon:3, title:'提示信息'},function(index){
            $.ajax({
                url:'/staff/store/destroy',
                type:'post',
                async:false,
                data:{
                    "_token": $("input[name=_token]").val(),
                    'id':id
                },
                dataType:'json',
                success:function (data) {
                    if(data.status == 1){
                        $('#store_'+id).remove();
                        layer.msg('删除成功！',{time:800});
                        // parent.location.reload();
                        layer.close(index);
                    }else{
                        layer.msg('删除失败！',{time:800});
                        layer.close(index);
                    }
                }
            })
            layer.close(index);
        });
    }
 function applyStore(id){  //渲染
            $.ajax({
                url:'/staff/store/contract',
                type:'post',
                async:false,
                data:{
                    "_token": $("input[name=_token]").val(),
                     'id':id, 
                },
                dataType:'json',
                success:function (data) {
                    if(data){
                          var aa = '';
                          if(data.status ==1){
                           aa = "已完成"
                          }else{
                           aa= "未完成"
                          }
                      var html="<p style='color: #1aa094;'>合同编号：<span style='color:red'>"+data.num+"</span><br>店主：<span style='color:red'>"+data.user+"</span>&nbsp;&nbsp;&nbsp;手机号：<span style='color:red'>"+data.user_phone+"</span><br>店铺配置：<span style='color:red'>"+data.details+"</span> 警号：<span style='color:red'>1</span>个<br>安装员：<span style='color:red'>"+data.setter+"</span>&nbsp;&nbsp;&nbsp;&nbsp;手机号：<span style='color:red'>"+data.setter_phone+"</span><br>业务员：<span style='color:red'>"+data.clerk+"</span>&nbsp;&nbsp;&nbsp;&nbsp;手机号：<span style='color:red'>"+data.clerk_phone+"</span><br>是否完成<span style='color:green'>&nbsp;&nbsp;"+aa+"</span><br></p>";
                          $('.apply_'+id).html(html);
                       }else{
                        $('.apply_'+id).remove()
                       }
                }
            })     
    }
</script>
</body>
</html>
